package store.service;

import org.springframework.stereotype.Service;
import store.dao.IDao;

import java.util.List;


@Service
public abstract class AbstractService<T> implements IService<T> {

    private IDao<T> dao;

    protected AbstractService() {
    }

    protected AbstractService(IDao<T> dao) {
        this.dao = dao;
    }

    @Override
    public void create(T entity) {
        dao.create(entity);
    }

    @Override
    public T read(Integer id) {
        return dao.read(id);
    }

    @Override
    public void update(T entity) {
        dao.update(entity);
    }

    @Override
    public void delete(T entity) {
        dao.delete(entity);
    }

    @Override
    public List<T> readAll() {
        return dao.readAll();
    }

    @Override
    public T findByField(String fieldName, Object value) {
        return dao.findByField(fieldName, value);
    }
}
